package com.ipzoe.app.controller;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.ipzoe.app.core.annotation.Login;
import com.ipzoe.app.core.constants.AppConstants;
import com.ipzoe.app.dto.FeedBackDTO;
import com.ipzoe.cms.domain.Feedback;
import com.ipzoe.cms.service.IFeedbackService;
import com.ipzoe.common.core.controller.BaseController;
import com.ipzoe.common.core.domain.AjaxResult;
import com.ipzoe.mem.domain.Member;
import com.ipzoe.mem.service.IMemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;

/**
 * 意见反馈Controller
 * 
 * @author lcl
 * @date 2020-08-29
 */
@RestController
@RequestMapping("api/v1/feedback")
@Api(tags = "意见反馈")
@Slf4j
public class FeedbackController extends BaseController
{
    @Autowired
    private IFeedbackService iFeedbackService;

    /**
     * 新增保存意见反馈
     */
    @Login
    @PostMapping("/add")
    @ApiOperation("提交意见反馈")
    public AjaxResult addSave(@RequestBody FeedBackDTO feedBackDTO, HttpServletRequest request)
    {
        Member member = (Member) request.getAttribute(AppConstants.REQUEST_ATTRIBUTE_KEY_MEMBER);

        Feedback feedback = new Feedback();
        feedback.setContent(feedBackDTO.getContent());
        feedback.setMobile(feedBackDTO.getMobile());
        feedback.setNickname(member.getNickname());
        feedback.setMemberId(member.getId());
        feedback.setStatus(0);
        iFeedbackService.save(feedback);
        return AjaxResult.success();
    }
}
